import Mock from 'mockjs'
import Common from './common.js'

const list = Mock.mock({
  'list|4-10': [
    {
      // 属性 id 是一个自增数，起始值为 1，每次增 1
      id: '@increment',
      timestamp: +Mock.Random.date('T'),
      author: '@first',
      reviewer: '@first',
      title: '@title(5, 10)',
      content_short: '我是测试数据',
      content: '@cparagraph',
      forecast: '@float(0, 100, 2, 2)',
      importance: '@integer(1, 3)',
      'type|1': ['CN', 'US', 'JP', 'EU'],
      'status|1': ['published', 'draft', 'deleted'],
      display_time: '@datetime',
      comment_disabled: true,
      pageviews: '@integer(300, 5000)',
      platforms: ['a-platform']
    }
  ]
})

const post = Mock.mock({
  content: '@cparagraph',
  source: '\u4e91\u5357\u7701\u53f8\u6cd5\u5385',
  post_time: '2018-10-08 11:10',
  video: '',
  img: ['/media/up/2018/10/8/9e0bd4bca454bcf63c7658dbe6e14773.png'],
  title: '@ctitle',
  view_count: 7,
  author: '@cname',
  id: '5bbac91be92c16645f4eb36f',
  desc: '@cparagraph(1,3)'
})

export default {
  list: () => {
    return Common.ajaxObj(list)
  },
  post: () => {
    return Common.ajaxObj(post)
  }
}
